﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinLotto
{
    public partial class frmMain : Form
    {
        private Random rand = new Random();
        private int gameType;
        public frmMain()
        {
            InitializeComponent();
        }

        public int randInt(int maxnum)
        {
            return rand.Next(1, maxnum + 1);
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void btnDraw_Click(object sender, EventArgs e)
        {
            if (cmbGameType.SelectedIndex < 0) { return; }
            int num;
            int maxnum = 0;
            int amount;

            if (cmbGameType.SelectedItem.ToString() == "Suomi")
            {
                maxnum = 39;
                gameType = 7;
            }
            else if (cmbGameType.SelectedItem.ToString() == "VikingLotto")
            {
                maxnum = 49;
                gameType = 8;  
            }
            else if (cmbGameType.SelectedItem.ToString() == "Eurojackpot")
            {
                maxnum = 50;
                gameType = 9;
            }


            string line = "";
            if (int.TryParse(tbDrawns.Text, out amount))
            {
                for (int j = 0; j < amount; j++)
                {
                    line = cmbGameType.SelectedItem.ToString() + " ";
                    for (int i = 0; i < gameType; i++)
                    {
                        num = randInt(maxnum);
                        line += num.ToString() + " ";
                    }
                    lbNums.Items.Add(line);
                    line = "";
                }
            }
        }

        private void btnClear_Click(object sender, EventArgs e)
        {
            lbNums.Items.Clear();
        }

        private void cmbGameType_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void tbDrawns_TextChanged(object sender, EventArgs e)
        {

        }

        private void rtbNums_TextChanged(object sender, EventArgs e)
        {

        }

        private void lbNums_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void lblGame_Click(object sender, EventArgs e)
        {

        }



    }
}
